package com.akl.ssmspringboot.controller;

import com.akl.ssmspringboot.service.AsyncService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 异步任务
 */
@RestController
@RequestMapping("asyn")
@EnableAsync
public class AsyncController {
    private final org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private AsyncService asyncService;

    /**
     * 异步处理2：使用springBoot自带async注解
     */
    @RequestMapping(value = "test1", method = RequestMethod.GET)
    public String test1() {
        asyncService.getTest1();
        logger.info("============>" + Thread.currentThread().getName());
        return "异步,正在解析......";
    }

}